import Vue from 'vue'
import VueRouter from 'vue-router'
var _import = (feild) => () => import(`@/views/${feild}.vue`)

Vue.use(VueRouter)

const routes = [{
		path: '/',
		redirect: '/login'
	},
	{
		path: '/login',
		name: 'login',
		component: _import('Login')
	},
	{
		path: '/index',
		name: 'index',
		component: _import('Index'),
		children: [{
				path: '/home',
				name: 'home',
				component: _import('Home')
			}, {
				path: '/sysUser',
				name: 'sysUser',
				component: _import('system/SysUser')
			}, {
				path: '/fm',
				name: 'fm',
				component: _import('content/Fm')
			}, {
				path: '/fmSort',
				name: 'fmSort',
				component: _import('content/FmSort')
			}, {
				path: '/article',
				name: 'article',
				component: _import('content/Article')
			},
			{
				path: '/sort',
				name: 'sort',
				component: _import('course/Sort')
			},
			{
				path: '/grade',
				name: 'grade',
				component: _import('consultant/Grade')
			},
			{
				path: '/counselor',
				name: 'counselor',
				component: _import('consultant/Counselor')
			},
			{
				path: '/field',
				name: 'field',
				component: _import('consultant/Field')
			},
			{
				path: '/welfare',
				name: 'welfare',
				component: _import('content/Welfare')
			},
			{
				path: '/knowledge',
				name: 'knowledge',
				component: _import('content/Knowledge')
			},
			{
				path: '/sysCompany',
				name: 'sysCompany',
				component: _import('system/SysCompany')
			},
			{
				path: '/sysMessage',
				name: 'sysMessage',
				component: _import('consultants/SysMessage')
			},
			{
				path: '/sysEvaluate',
				name: 'sysEvaluate',
				component: _import('consultants/SysEvaluate')
			},
			{
				path: '/sysBooking',
				name: 'sysBooking',
				component: _import('booking/SysBooking')
			},
			{
				path: '/sysIntegral',
				name: 'sysIntegral',
				component: _import('Integral/SysIntegral')
			}, {
				path: '/articleSort',
				name: 'articleSort',
				component: _import('content/ArticleSort')
			}, {
				path: '/courseVideos',
				name: 'courseVideos',
				component: _import('course/CourseVideos')
			}, {
				path: '/psyAssess',
				name: 'psyAssess',
				component: _import('assess/PsyAssess')
			}, {
				path: '/psyAssessSort',
				name: 'psyAssessSort',
				component: _import('assess/PsyAssessSort')
			}, {
				path: '/consultantFees',
				name: 'consultantFees',
				component: _import('consultant/ConsultantFees')
			}, {
				path: '/consultantFeeSort',
				name: 'consultantFeeSort',
				component: _import('consultant/ConsultantFeeSort')
			}, {
				path: '/counselorOrder',
				name: 'counselorOrder',
				component: _import('consultant/CounselorOrder')
			}, {
				path: '/courseEvaluate',
				name: 'courseEvaluate',
				component: _import('course/CourseEvaluate')
			}, {
				path: '/courseOrder',
				name: 'courseOrder',
				component: _import('course/CourseOrder')
			}, {
				path: '/courseVideos',
				name: 'courseVideos',
				component: _import('course/CourseVideos')
			}, {
				path: '/reply',
				name: 'reply',
				component: _import('queAndAnse/Reply')
			}, {
				path: '/query',
				name: 'query',
				component: _import('queAndAnse/Query')
			}, {
				path: '/notice',
				name: 'notice',
				component: _import('notice/Notice')
			}, {
				path: '/course',
				name: 'course',
				component: _import('course/Course')
			}
		]
	}

]
const router = new VueRouter({
	routes
})
router.beforeEach((to, from, next) => {
	if (to.path == '/login') {
		next();
	} else if (!sessionStorage.getItem('logonInfe')) {
		next('/login')
	} else {
		next()
	}
})



export default router